<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>简易叠层判断</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    .test {
      position: relative;
      width: 100px;
      height: 100px;
      top: 220px;
      left: 101px;
      background-color: red;
      opacity: 0.1;
      z-index: 2;
    }

    .cover {
      position: absolute;
      width: 200px;
      height: 200px;
      top: 150px;
      left: 30px;
      background-color: green;
      opacity: 0.1;
      z-index: 2;
    }
  </style>
</head>

<body>
  <div class="test"></div>
  <div class="cover"></div>
  <script src="./js/cover.js"></script>
  <script>
    let res = new Cover("div.test").isCover();
    console.log('-- 检测结果：--', res ? '有叠层' : "没有叠层");
  </script>
</body>

</html>